/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Login;

//import edu.ipfw.cs590.cheat.AccessType;
//import edu.ipfw.cs590.cheat.Person;
//import edu.ipfw.cs590.cheat.RegisteredUser;
import edu.ipfw.cs590.cheat.AssignmentManagementInterface;
import edu.ipfw.cs590.cheat.RegisteredPerson;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;

/**
 *
 * @author rrm46582
 */
public class Main {
    static List<RegisteredPerson> pendingUsers;

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        try
        {
            callLogin("r.r@m.com", "r.r@m.com");
        } 
        catch (MalformedURLException ex)
        {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }
    }


 
 private static int callLogin(String id, String pwd) throws MalformedURLException
    {

        URL wsdlURL = null;
		try
		{
			wsdlURL = new URL("http://robinrmcomputer:8080/CheatApp-war/AssignmentManagementService?wsdl");
            QName serviceQName = new QName("HTTP://cheat.cs590.ipfw.edu","AssignmentManagementService");
			QName portQName =    new QName("HTTP://cheat.cs590.ipfw.edu","AssignmentManagementSOAP");
            Service service = null;
            service = Service.create(wsdlURL, serviceQName);

            AssignmentManagementInterface jiPort =
                    (AssignmentManagementInterface)  service.getPort(portQName,AssignmentManagementInterface.class);


            String answer;
            //answer = jiPort.login("sarcasm@sarcasm.org", "sarcasm");
            //System.out.println("Admin session id: " + answer);
            System.out.println("Login with:" + id + "/" + pwd);
            answer = jiPort.login(id, pwd);
            System.out.println("Inst session id: " + answer);
            return new Integer(answer);
		}
		catch (NumberFormatException ex)
        {
            System.out.println("Login Failed!!!!!!");
            return -1;
        }
        catch (MalformedURLException e)
		{
			e.printStackTrace();
            return -1;
		}

    }


}
